from smtplib import SMTP
from email.header import Header
from email.mime.text import MIMEText
import requests


def seed_email():
    sender = '676327223@qq.com'
    receivers = ['yuxian158@gmail.com', '1184659929@qq.com']
    message = MIMEText('函数执行失败.', 'plain', 'utf-8')
    message['From'] = Header('676327223@qq.com', 'utf-8')
    message['To'] = Header('张洛', 'utf-8')
    message['Subject'] = Header('执行结果通知', 'utf-8')
    smtper = SMTP('smtp.qq.com')
    # 请自行修改下面的登录口令
    smtper.login(sender, 'nynmwlyrfzwhbfjg')
    smtper.sendmail(sender, receivers, message.as_string())
    print('邮件发送完成!')


def send_message(text="成功"):
    """通过server发送消息"""
    url = "https://sc.ftqq.com/SCU109609T90a19808fcd9967a40f07213d2f7e8f25f38e5ccc9270.send"
    data = {'text': text}
    try:
        requests.post(url=url, data=data)
    except:
        print('发送失败')
